<?php
/**
 * coreRouterMapQuery
 *
 * 라우팅 맵 - Querystring 방식
 *
 * @package router
 * @author  Platform Team
 */

class coreRouterMapQuery extends coreRouterMapAbstract
{
    const PARAM_CONTROLLER      = 'controller';
    const PARAM_METHOD          = 'method';

    /**
     * Map Parse
     */
    public function parse()
    {
        $this->setController();
        $this->setMethod();
    }

    /**
     * 컨트롤러 세팅
     */
    private function setController()
    {
        $sCont = $_GET[self::PARAM_CONTROLLER];
        $sCont = $this->stripFirstSlashes($sCont);

        $result = $this->parsePath($sCont);

        if ($result === false) {
            $this->sErrorMsg = 'Controller parse error : ' . $sCont;
            return;
        }

        $this->sController = $result['controller'];
        $this->sControllerPath = $result['path'];
    }

    /**
     * 메소드 세팅
     */
    private function setMethod()
    {
        $this->sMethod = $_GET[self::PARAM_METHOD] ?  $_GET[self::PARAM_METHOD] : FW_ROUTE_DEFAULT_METHOD;
    }
}
